<?php

namespace backend\controllers;

/**
 * @author  shuang
 * @date    2016-8-4 17:13:37
 * @version V1.0
 * @desc    
 */
use yii\web\Controller;
class CreatefileController extends Controller {

    public $layout = false;

    //获取后台管理菜单数据
    public function actionGetmenus() {
        $res = \backend\models\MY_Mgmt::getMenuData();
        echo "<?php\n return \n'" . json_encode($res) . "';";
    }

    //获取后台字典信息
    public function actionGetdicts() {
        $res = \backend\models\MY_Dictionary::find()->all();
        $temp = [];
        foreach ($res as $item) {
            if ($item->column_id === 0) {
                $temp[$item->id] = $item->attributes;
            } else {

                $temp[$item->column_id]["son"][] = $item->attributes;
            }
        }
        foreach ($temp as $key => $item) {
            if (\yii\helpers\ArrayHelper::getValue($item, "son")) {
                $itemattr = $item["son"];
                \yii\helpers\ArrayHelper::multisort($itemattr, "sortid", SORT_DESC);
                $temp[$key]["son"] = $itemattr;
            }
        }
        echo "<?php\n return \n'" . json_encode($temp) . "';";
    }

    /*
     * 获取任务类型及相关属性
     */

    public function actionGettaskattribute() {
        $res = \backend\models\MY_TaskPrice::getTaskAttributes();
        echo "<?php\n return \n'" . json_encode($res) . "';";
    }

}
